﻿using System.IO;

namespace CrazyTalk.Common
{
    public class DicHelper
    {
        public static void DeleteFolder(string dir)
        {
            if (Directory.Exists(dir)) //如果存在这个文件夹删除之 
            {
                foreach (string d in Directory.GetFileSystemEntries(dir))
                {
                    if (File.Exists(d))
                        File.Delete(d); //直接删除其中的文件 
                    else
                        DeleteFolder(d); //递归删除子文件夹 
                }
                Directory.Delete(dir); //删除已空文件夹                 
            }
        }

        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="delFile"></param>
        public static void Delete(string delFile)
        {
            File.Delete(delFile);
        }

        public static void MoveFile(string srcFileName, string destFileName)
        {
            File.Move(srcFileName, destFileName);
        }

        public static void MoveDirectory(string srcFolderPath, string destFolderPath)
        {
            Directory.Move(srcFolderPath, destFolderPath);
        }
    }
}
